<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta http-equiv="Expires" CONTENT="0">
    <meta http-equiv="Cache-Control" content="no-siteapp,no-transform,no-store, no-cache, must-revalidate">
    <meta http-equiv="Pragma" content="no-cache">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="/static/css/font.css">
    <link rel="stylesheet" href="/static/css/weadmin.css">
    <script type="text/javascript" src="/lib/layui/layui.js" charset="utf-8"></script>
    <link rel="stylesheet" href="/static/css/buildUnit/common.css">
    <script type="text/javascript" src="/lib/mxDraw/mxcustom.js"></script>
    <style>
        body {
            padding: 10px;
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
        }

        #content {
            height: 100%;
        }

        .drawingObj {
            height: 100%;
            width: 100%;
        }
    </style>
</head>
<body>
<div id="content">

</div>
<script src="/static/js/main.js"></script>
<script>
    var $;
    var configure;
    var fileName;
    var id;
    var attId;
    var token;
    layui.use([
        'layer',
        'mxDraw',
        'configure',
        'sessionFun',
        'matchType',
        'bluebird',
        'pdf',
        'jquery',
        'bluebird'
    ], function () {
        configure = layui.configure;
        var mxDraw = layui.mxDraw;
        var sessionFun = layui.sessionFun;
        var matchType = layui.matchType;
        var pdf = layui.pdf;
        $ = layui.jquery;
        //获取图纸对象
        var signData = sessionFun.get(configure.SESSION_SIGN_DATA);
        //获得图纸真实名称
        var fileName = signData.fileName;
        id = signData.id;
        attId = signData.attId;
        token = sessionFun.get(configure.SESSION_TOKEN) ? sessionFun.get(configure.SESSION_TOKEN).token : '';
        console.log("signData"+signData);

        //pdf文件下载地址
        var url = configure.HOST + "/api/cpt/acceptance/supervise/gcjgysjdjl1File/download?cptId="+id+"&token="+token+"&attId="+attId;
        pdf.init('drawingId', url, '#content');
    });

    function signSave() {
        return new Promise(function (resolve, reject) {
            var url = configure.HOST + '/api/cpt/acceptance/supervise/gcjgysjdjl1File/sign' + '?cptId=' + id + '&attId=' + attId + "&token="+token;
            var status = $('#drawingId')[0].HttpClient.UploadToServer(url);
            var timer = setInterval(function () {
                if (status == 200) {
                    clearTimeout(timer);
                    resolve({code: 1, msg: '签名保存成功'});
                } else {
                    clearTimeout(timer);
                    resolve({code: 0, msg: '签名保存失败'});
                }
            }, 1000)
        })
    }

</script>
</body>
</html>